import { post , get, put , del } from '../../utils/request';

interface DocArchiveRresponse {
  code: number;
  msg: string;
  status: boolean;
  data: any;
  fail: boolean;
}

interface DocArchiveBaseDTO {
	id?:number;
	userId?:string;
	writingRecordId?:number;
	title?:string;
	content?:string;
	writingType?:string;
	isShared?:number;
}
/**
 * 获取系统知识库列表
 */
export const getSharedDocArchiveList = (pageNum?:number,pageSize?:number): Promise<DocArchiveRresponse> => {
  return get(`/api/starhub/docArchive/shared/list`,{ pageNum, pageSize });
};

/**
 * 获取个人知识库列表
 */
export const getPersonalDocArchiveList = (pageNum?:number,pageSize?:number): Promise<DocArchiveRresponse> => {
  return get(`/api/starhub/docArchive/personal/list`,{ pageNum, pageSize });
};

export const getSearchDocArchiveList = (pageNum?:number,pageSize?:number,keyWord?:string,type?:number): Promise<DocArchiveRresponse> => {
  return get(`/api/starhub/docArchive/search/list`,{ pageNum, pageSize,keyWord,type });
};

/**
 * 获取已关注的知识库列表
 */
export const getFollowedArchiveList = (pageNum?:number,pageSize?:number): Promise<DocArchiveRresponse> => {
  return get(`/api/starhub/docArchive/followed/list`,{ pageNum, pageSize });
};
/**
 * 分享到系统知识库
 */
export const shareDocArchive = (id:number): Promise<DocArchiveRresponse> => {
  return put(`/api/starhub/docArchive/share/${id}`);
};
/**
 * 取消分享
 */
export const unshareDocArchive = (id:number): Promise<DocArchiveRresponse> => {
  return put(`/api/starhub/docArchive/unshare/${id}`);
};

/**
 * 获取知识库详情
 */
export const getDocArchiveById = (id:number): Promise<DocArchiveRresponse> => {
  return put(`/api/starhub/docArchive/query/${id}`);
};

/**
 * 新建知识库
 */
export const createDocArchive = (data:Partial<DocArchiveBaseDTO>): Promise<DocArchiveRresponse> => {
  return post(`/api/starhub/docArchive/create`,data);
};
/**
 * 更新知识库
 */
export const updateDocArchive = (data:Partial<DocArchiveBaseDTO>): Promise<DocArchiveRresponse> => {
  return post(`/api/starhub/docArchive/edit`,data);
};
/**
 * 删除知识库
 */
export const deleteDocArchive = (id:number): Promise<DocArchiveRresponse> => {
  return del(`/api/starhub/docArchive/delete/${id}`);
};
/**
 * 关注知识库
 */
export const followArchive = (id:number): Promise<DocArchiveRresponse> => {
  return post(`/api/starhub/docArchive/follow/${id}`);
};

/**
 * 取消关注知识库
 */
export const unfollowArchive = (id:number): Promise<DocArchiveRresponse> => {
  return del(`/api/starhub/docArchive/unfollow/${id}`);
};

/**
 * 
 */
export const getContentByFileId = (data:{id:number}): Promise<DocArchiveRresponse> => {
  return post(`/api/starhub/document/getContentByFileId`,data);
};

